package find.prj.lib;

public class SerialFileSearch implements Searcher {
	
	public SerialFileSearch() {
	}

	@Override
	public String getSearchResults(String searchKeyWord, String[] rootPaths, String excludeKeyWord) {
		FileNamesStringArray resultList = new FileNamesStringArray();
		for(int i=0; i < rootPaths.length; i++) {
			resultList.add(FileNamesStringArray.FILTERED_FILE_NAMES_DELIMITER);
			FileSearch search = new FileSearch(searchKeyWord, rootPaths[i], excludeKeyWord);
			search.filterFileNames();
			search.excludeFileNames();
			FileNamesStringArray filteredFileNames = search.getFilteredFileNames();
			if (! filteredFileNames.isEmpty())
				resultList.addAll(filteredFileNames);
			resultList.add(FileNamesStringArray.EXCLUDED_FILE_NAMES_DELIMITER);
			FileNamesStringArray excludedFileNames = search.getExcludedFileNames();
			if (! excludedFileNames.isEmpty())
				resultList.addAll(search.getExcludedFileNames());
		}
		return resultList.toString();
	}
}